<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学生修改</title>
    <script src="../../js/jquery.js"></script>
    <script src="../../js/common.js"></script>
  <script>
      window.onload=function(){
          //得到学生编号
          let id=obj.getValue2(location.search,"id");
          $.get(url+"StuOne",{id:id},function(data){
              $("input[name=sname]").val(data.sname);
              $("input[name=sage]").val(data.sage);
              //选中性别  字符串数组
              let　aihao=data.saihao.split(";");
              $("input[name=saihao]").each(function(i,obj){
                  if (aihao.includes(obj.value))
                      obj.checked=true;
                  else
                      obj.checked=false;
              })
          },"json");
      }
    function tijiao(){
       $.get(url+"StuInsert",$("form").serialize(),function (data){
         if (data==1)
           alert("成功");
         else
           alert("失败");
       });
      return false;
    }
  </script>
</head>
<body>
  <form onsubmit="return tijiao()">
    <table>
      <tr>
        <td>姓名</td>
        <td><input type="text" name="sname"></td>
      </tr>
      <tr>
        <td>年龄</td>
        <td><input type="text" name="sage"></td>
      </tr>
      <tr>
        <td>性别</td>
        <td>
<!--          label中的for与按钮中的id一一对应，可实现选中-->
          <input type="radio" value="男" id="male" name="ssex">
          <label for="male">男</label>
          <input type="radio" value="女" id="female" name="ssex">
          <label for="female">女</label>

        </td>
      </tr>
      <tr>
        <td>爱好</td>
        <td>
<!--          label中的for与按钮中的id一一对应，可实现选中-->
          <input type="checkbox" value="读书" id="reading" name="saihao">
          <label for="reading">读书</label>
          <input type="checkbox" value="运动" id="sport" name="saihao">
          <label for="sport">运动</label>

        </td>
      </tr>
      <tr>
        <td colspan="2">
          <input type="submit" value="提交">
          <input type="reset" value="重置">
        </td>
      </tr>
    </table>
  </form>
</body>
</html>